/**
 *
 * @param {Array} menulist 用户的菜单信息，用于和allRoutes 进行对比
 * @param {Array} allRoutes 用户的完整动态路由表
 */
let recursionRoutes = (menulist = [], allRoutes = []) => {
  //用于放置对比之后的路由数据
  let userRoutes = [];
  menulist.forEach((menu) => {
    //一个menu结构：{id: '1', title: 'glsy', name: '管理首页'}
    allRoutes.forEach((route) => {
      //一个route结构：
      // {"path": "welcome", "meta": { "title": "glsy","name": "管理首页","routeName": "welcome"},"id": "welcome"}
      if (menu.title === route.meta.title) {
        if (menu.children && menu.children.length > 0) {
          route.children = recursionRoutes(menu.children, route.children);
        }
        userRoutes.push(route);
      }
    });
  });
  return userRoutes;
};
export default recursionRoutes;
